package com.ywj.collection.Collections;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class CollectionsDemo1 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        //原来写法
        list.add(9);
        list.add(8);
        list.add(320);
        list.add(14);
        System.out.println(list);  //[9, 8, 320, 14]

        //将集合中元素按照默认的自然规则排序
        Collections.sort(list);
        System.out.println(list);  //[8, 9, 14, 320]

        //打乱集合顺序
        Collections.shuffle(list);
        System.out.println(list);  //[320, 8, 14, 9]

    }
}
